package com.ccbft.msgcenter.mc.message.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.ccbft.msgcenter.mc.message.service.MessageSendService;

@RestController
@RequestMapping(value="send")
public class MessageProductContoller {

	@Autowired
	private MessageSendService kafkaMessageSendService;

	@RequestMapping(value = "/sendMessage/{topic}", method = RequestMethod.POST)
	public String urlProducer(@PathVariable("topic") String topic,@RequestBody String message) {
		//TODO:1.新增一个参数，判断这个消息类型Topic， 2.根据消息类型选配置。  3。将配置的metadata和消息一起transfer   4.transfer链式处理完后，送给kafka。
		try {
			kafkaMessageSendService.send(topic,message);
		} catch (Exception e) {
			return "send failed.";
		}
		return message;
	}
}
